# -*- coding: utf-8 -*-
"""
author:码同学 极光
date:2023-02-04
desc: 
sample: 
"""
import os

from locust import HttpUser, task


class Login(HttpUser):
    host = 'http://82.156.74.26:9088/pinter'

    @task  # locust
    def login(self):
        url = self.host + '/com/login'
        data = {"userName": 'admin', 'password': '1234'}
        with self.client.post(url=url, data=data, catch_response=True, timeout=5) as response:
            #if response.json()['message'] == 'success':
            if response.json().get('message') == 'success':
                response.success()
            else:
                response.failure(response.json())


if __name__ == '__main__':
    os.system('locust -f Login.py')
